<?php

class Comment_Collection extends Collection
{
	public function Comment_Collection()
	{
		parent::Collection("comment", "id");
	}

	public function getComments($id)
	{
		$sql = new SQLAdapt();
		$req = "select * from comment where articleId = $id order by creation_date ASC;";

		$res = $sql->query($req);
		if($res != null && $res->rowCount() > 0)
		{
			$coms = array();
			foreach($res as $r)
			{
				//$r = $r->fetch();
				$constructeur = "Comment_Modele::getRef";
				// On construit la liste des paramètres
				for($i=0;$i<$this->_nbField;$i++)
					$param[$i] = $r[$i];
				// On construit l'occurence
				array_push($coms, call_user_func_array($constructeur, $param));
			}
			
			return $coms;
		}
		else
			return null;
	}
}

?>
